<?php

namespace App\Jobs\FuYou;

use App\Service\FuYou\FuYouService;
use App\Service\WorkOrder\Web\ApplyService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class FuYouSendEmailAutoJob implements ShouldQueue
{

    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private array $data;

    /**
     * 富友自动进件-发送邮件
     * @param array $data
     */
    public function __construct(array $data)
    {
        $this->data = $data;
    }

    /**
     * 富友自动进件-发送邮件
     * @return void
     */
    public function handle()
    {
        Log::info("富友自动进件-发送邮件 Queue debug...", $this->data);

        $fuYouService = new FuYouService();
        switch ($this->data['type']) {
            case ApplyService::SEND_EMAIL_TYPE_SECONDARY_BINDING://1-重新发送一二级绑定邮件
                $fuYouService->secondaryBindingSendEmail($this->data['workOrderNo'], $this->data['companyName'], $this->data['fyMchntCd']);
                break;
            case ApplyService::SEND_EMAIL_TYPE_SYSTEM_APPLY://2-重新发送前置系统申请邮件
                $fuYouService->preSecretApplySendEmail($this->data['workOrderNo'], $this->data['companyName'], $this->data['fyMchntCd']);
                break;
            default:
                break;
        }
        Log::info("富友自动进件-发送邮件 Queue end..." . $this->data['workOrderNo']);
    }
}
